
local ElementLayout = _ENV.import("./ElementLayout.lua");
local ElementUI = commonlib.inherit(ElementLayout);


function ElementUI:GetPainter()
    return self:GetWindow():GetPainter();
end

function ElementUI:OnBeforeRender()
end

function ElementUI:OnRender()
    local painter = self:GetPainter();
    local x, y = self:GetWindowXY();
    local width, height = self:GetWidthHeight();
    local background_color = self:GetBackgroundColor();
    -- print(x, y, width, height, background_color, 0)
    painter:DrawRectangle(x, y, width, height, background_color, 0);
end

function ElementUI:OnBeforeRenderChildren()
end

function ElementUI:OnRenderChildren()
end

function ElementUI:OnAfterRenderChildren()
    for children in self:ChildrenIterator() do
        children:Render();
    end
end

function ElementUI:OnRenderScrollBar()
end

function ElementUI:OnAfterRender()
end

function ElementUI:Render()
    self:OnBeforeRender();
    self:OnRender();
    self:OnBeforeRenderChildren();
    self:OnRenderChildren();
    self:OnAfterRenderChildren();
    self:OnRenderScrollBar();
    self:OnAfterRender();
end
return ElementUI;